﻿// Open Source: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Project: YoProgramo.NET (http://code.google.com/p/yoprogramo/)
// Autor: Fabian Figueredo (info@fabianfigueredo.com.ar)
// Blog: blog.yoprogramo.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace YoProgramo.Infrastructure.Tools.Configuration
{
    public static class YoProgramoConfigurationManager {
        public static YoProgramoConfiguration Configure()
        {
            YoProgramoConfiguration yp = (YoProgramoConfiguration)System.Configuration.ConfigurationSettings.GetConfig("YoProgramoConfig");
            HttpContext.Current.Cache.Insert("YoProgramoConfiguration", yp);
            return yp;
        }

        public static YoProgramoConfiguration GetCurrentConfiguration()
        {
            YoProgramoConfiguration yp = HttpContext.Current.Cache["YoProgramoConfiguration"] as YoProgramoConfiguration;
            if (yp == null)
                return Configure();

            return yp;
        }

        public static string GetSiteName() {
            return GetCurrentConfiguration().SiteName;
        }

        public static bool IsSiteLocked() {
            return GetCurrentConfiguration().IsSiteLocked;
        }

        public static bool IsRegistrationLocked() {
            return GetCurrentConfiguration().IsRegistrationLocked;
        }
    }
}